<template>
	<div class="w-100">
		<div class="tabs-content" v-if="!showResult">
			<el-scrollbar max-height="80vh" class="active-item">
				<BaseInfo v-if="active == 1" ref="formRef" @submit="onChange"></BaseInfo>
				<Extend v-if="active == 2" ref="formRef" @submit="onChange"></Extend>
				<Other v-if="active == 3" ref="formRef" @submit="onChange"></Other>
			</el-scrollbar>
			<div class="fc">
				<el-button class="ap-btn" type="primary" @click="handleSubmit('submit')"> 提交保存 </el-button>
			</div>
		</div>
		<DataGather
			v-else
			changeType="养老机构"
			:dataType="2"
			:name="nowRowData.organizationName"
			:active="active"
			@backNext="handleBackNext"
			@back="handleBack"
			@init="getInitMod"
		></DataGather>
	</div>
</template>

<script setup lang="ts">
import BaseInfo from './BaseInfo/index.vue'
import Extend from './Extend/index.vue'
import Other from './Other/index.vue'
import DataGather from '@/views/datacenter/components/DataGather/change/index.vue'
import { useCommonStore } from '@/stores/common'
const { tempNowObj } = storeToRefs(useCommonStore())

type Props = {
	nowRowData?: any
}
const props = withDefaults(defineProps<Props>(), {})
const emit = defineEmits(['refresh'])

provide('nowRowData', props.nowRowData)

const formRef = ref(null)
const active: any = ref(tempNowObj.value?.active || 1)
const showResult = ref(false)
const operateType = ref('')

let rechangeData = ref({})
provide('rechangeData', rechangeData)

const getInitMod = () => {
	active.value = 1
	showResult.value = false
}

const handleSubmit = (type) => {
	operateType.value = type
	formRef.value!.onSave()
}
const handleBackNext = () => {
	showResult.value = false
	emit('refresh')
}
const handleBack = () => {
	showResult.value = false
}
const onChange = (data) => {
	showResult.value = true
}
</script>

<style scoped lang="scss">
.active-item {
	padding: 1rem;
	margin: 1rem;
}
</style>
